package logic

import (
	"bilibili/bilibilirpc/bilibilirpc"
	"context"

	"bilibili/api/internal/svc"
	"bilibili/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserRealnameUpdatesLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserRealnameUpdatesLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserRealnameUpdatesLogic {
	return &UserRealnameUpdatesLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserRealnameUpdatesLogic) UserRealnameUpdates(req *types.UserRealnameUpdatesRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	updates, err := l.svcCtx.BilibiliRpc.UserRealnameUpdates(l.ctx, &bilibilirpc.UserRealnameUpdatesRequest{
		Name:     req.Name,
		IdCard:   req.IdCard,
		Status:   req.Status,
		UserId:   req.UserId,
		Password: req.Password,
		Mobile:   req.Mobile,
		Id:       req.Id,
	})
	if err != nil {
		return &types.Response{
			Code:    500,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Code:    200,
		Message: "修改成功",
		Data:    updates,
	}, nil
}
